package com.jucai.pppeiyouclient.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.bean.OrderBean;
import com.jucai.pppeiyouclient.view.activity.CommonH5Activity;

import java.util.List;

public class OrderListBakAdapter extends RecyclerView.Adapter<OrderListBakAdapter.ViewHolder> {

    private Activity mActivity;
    private List<OrderBean> mList;

    public OrderListBakAdapter(Activity activity, List<OrderBean> list) {
        this.mActivity = activity;
        this.mList = list;
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {

        final OrderBean orderBean = mList.get(position);

        holder.mainRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CommonH5Activity.startCommH5(mActivity, 1, orderBean.getURL(), null, orderBean.getTorder_id(), null);
            }
        });

    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup group, int viewType) {
        View view = LayoutInflater.from(group.getContext()).inflate(R.layout.item_order_layout_list, group, false);
        return new ViewHolder(view);
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private RelativeLayout mainRelativeLayout;
        private ImageView imgImageView;
        private TextView nameTextView;
        private TextView infoTextView;
        private TextView createTimeTextView;
        private TextView startTimeTextView;
        private TextView addressTextView;

        private ViewHolder(View view) {
            super(view);

            mainRelativeLayout = (RelativeLayout) view.findViewById(R.id.main_relative_layout);
            imgImageView = (ImageView) view.findViewById(R.id.order_user_img);
            nameTextView = (TextView) view.findViewById(R.id.order_user_name);
            infoTextView = (TextView) view.findViewById(R.id.order_user_info);
            createTimeTextView = (TextView) view.findViewById(R.id.order_create_time);
            startTimeTextView = (TextView) view.findViewById(R.id.order_start_time);
            addressTextView = (TextView) view.findViewById(R.id.order_see_address);

        }

    }

}
